import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  username: ''
}
// mutations里面放的函数专门用来修改state中的值的
const mutations = {
  // setUserName: (state, uname) => {
  //   localStorage.setItem('username', uname)
  //   state.username = uname
  // }
}
const actions = {}
const getters = {
  getterName:state=>state?localStorage.getItem('username'):localStorage.getItem('username')
}

export default new Vuex.Store({
  state,
  getters,
  actions,
  mutations
})
